package com.magic.smartcity.view.more.bus

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TableLayout
import androidx.fragment.app.Fragment
import com.google.android.material.tabs.TabLayoutMediator
import com.magic.smartcity.databinding.FragmentBusOrderBinding
import com.magic.smartcity.view.more.adapters.BusOrderTabLayoutAdapter

class BusOrderFragment : Fragment() {
    private lateinit var binding: FragmentBusOrderBinding
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentBusOrderBinding.inflate(layoutInflater)
        initView()
        return binding.root
    }

    private fun initView() {
        //重点,ViewPage2和TabLayout使用方法
        binding.viewPageContent.adapter =
            BusOrderTabLayoutAdapter(parentFragmentManager, lifecycle)
        TabLayoutMediator(binding.tableLayout, binding.viewPageContent) { tab, position ->
            when (position) {
                0 -> tab.text = "未支付"
                1 -> tab.text = "已支付"
            }
        }.attach()//最后一步一定要将ViewPage2根TabLayout绑定
    }

}